﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Ex4.FindStudentsByAge
{
    class FindStudentsByAge
    {
        class Student
        {
            public string FirstName { get; set; }
            public string LastName { get; set; }
            public int Age { get; set; }
        }

        static IEnumerable<Student> FilterStudents(Student[] students)
        {
            var filteredStudents =
                from student in students
                where student.Age > 18 && student.Age<24
                select student;
            return filteredStudents;
        }

        static void Main(string[] args)
        {
            Student[] students = new Student[] 
                                        { 
                                            new Student { FirstName = "Alex", LastName = "Buchkov" , Age = 17 } ,
                                            new Student { FirstName = "Bobi", LastName = "Cickov"  , Age = 19} ,
                                            new Student { FirstName = "Lisa", LastName = "Kirova"  , Age = 23} ,
                                        };
            var filteredStudents = FilterStudents(students);
            if (filteredStudents.Count() > 0)
            {
                Console.WriteLine("Students with age between 18 and 24:\n");
            }
            foreach (var student in filteredStudents)
            {
                Console.WriteLine("{0,-10}{1,-10}", student.FirstName, student.LastName);
            }
            Console.WriteLine();
        }
    }
}
